<?php

namespace App\Http\Middleware;

use Auth;
use Closure;
use Redirect;

class Authenticate extends \Illuminate\Auth\Middleware\Authenticate
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @param  string[]  ...$guards
     * @return mixed
     *
     * @throws \Illuminate\Auth\AuthenticationException
     */
    public function handle($request, Closure $next, ...$guards)
    {
        $this->authenticate($guards);

        if(Auth::user()->status == config("constants.user.status.ban")){
            Auth::logout();
            return Redirect::to( '/login');
        }

        return $next($request);
    }
}